package com.JZ.QM.scheduledTasksService;

import com.JZ.QM.service.ComEarningRecordService;
import com.JZ.QM.service.ProductEarningRecordService;
import com.JZ.QM.service.TotalEarningRecordService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author: cyc
 * @email cyc@gmail.com
 * @date: 2020/7/11 20:40
 */
@Service
public class EarningRecordService {
    @Resource
    ProductEarningRecordService productEarningRecordService;
    @Resource
    ComEarningRecordService comEarningRecordService;
    @Resource
    TotalEarningRecordService totalEarningRecordService;

    /**
     * 更新产品日收益
     */
    @Scheduled(cron="0 51 0 * * *")
    public void updateProductEarningList(){
        //产品更新状态
        boolean updateState=false;
        //进行产品的收益更新
        updateState=productEarningRecordService.caculateProductEarning();
        //输出更新状态
        if(updateState){
            System.out.println("产品收益率已经更新");
        } else {
            System.out.println("茶品收益率更新失败");
        }

    }

    /**
     * 更新组合日收益
     */
    @Scheduled(cron="0 52 0 * * *")
    public void updateComEarningList(){
        //组合更新状态
        boolean updateState=false;
        //进行组合的收益更新
        updateState=comEarningRecordService.caculateComEarning();
        //输出更新状态
        if(updateState){
            System.out.println("产品收益率已经更新");
        } else {
            System.out.println("茶品收益率更新失败");
        }

    }

    /**
     * 更新用户的累积日收益
     */
    @Scheduled(cron="0 53 0 * * *")
    public void updateTotalEarningList(){
        //用户总收益更新状态
        boolean updateState=false;
        //用户总收益的收益更新
        updateState=totalEarningRecordService.caculateTotalEarning();
        //输出更新状态
        if(updateState){
            System.out.println("产品收益率已经更新");
        } else {
            System.out.println("茶品收益率更新失败");
        }
    }
}
